package at.dl.android.dota.adviser;

import android.view.View;
import android.view.ViewGroup;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.TextView;
import at.dl.android.dota.adviser.R;

public class GalleryItemImageAdapter extends AbstractGalleryAdapter {

    private final int[] totalCosts;

    GalleryItemImageAdapter ( Gallery gallery, ActivityWithDB avticity, int[] ids, String[] names, int[] totalCosts ) {
        super(gallery,avticity,ShowItemActivity.class,ShowItemActivity.ITEM_NAME,ids,names);
        this.totalCosts = totalCosts;
    }

    @Override
    public View getView ( int position, View convertView, ViewGroup parent ) {
        final View view = mInflater.inflate(R.layout.item_entry,parent,false);
        ImageView imageView = (ImageView) view.findViewById(R.id.img);
        imageView.setImageResource(ids[position]);
        if ( ids[position] != R.drawable.recipe ) {
            imageVie2TextMap.put(imageView,names[position]);
            imageView.setOnClickListener(this);
        }
        TextView t = (TextView) view.findViewById(R.id.name);
        t.setText(names[position]);
        t = (TextView) view.findViewById(R.id.price);
        t.setText(Integer.toString(totalCosts[position]));
        return view;
    }
}
